package com.guan.study.easyExcelDemo.utils;


import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.StringUtils;



/**
 * @Date: 2023/7/20 10:32
 * @Author: yaobai
 * @Description: 数值转换器
 */
public class CustomConverter implements Converter<String> {

    @Override
    public WriteCellData<String> convertToExcelData(String value, ExcelContentProperty contentProperty,
                                                    GlobalConfiguration globalConfiguration) throws Exception {
        if (StringUtils.isNotBlank(value)){

            if (EnumDemo.SCHOOL_0.getCode().equals(value)){

                return new WriteCellData<>(EnumDemo.SCHOOL_0.getMessage());

            }else if (EnumDemo.SCHOOL_1.getCode().equals(value)){

                return new WriteCellData<>(EnumDemo.SCHOOL_1.getMessage());

            }else if (EnumDemo.SCHOOL_2.getCode().equals(value)){

                return new WriteCellData<>(EnumDemo.SCHOOL_2.getMessage());

            }
        }
        return new WriteCellData<>("");

    }

}
